<?php
/**
 * Helper Acl controller.
 *  
 * @author Nguyen Hai Ha
 * @version 1.0
 */

class Hanh_Controller_Action_Helper_Acl extends Zend_Controller_Action_Helper_Abstract {
	/**
	 * @var Hanh_Controller_Plugin_Acl
	 **/
	protected $_aclPlugin;
	
	/**
	 * Constructor
	 *
	 * @return void
	 **/
	function __construct() {
		$this->_aclPlugin = $this->getAclPlugin ();
	}
	
	/**
	 * Returns the Acl Plugin object
	 *
	 * @return Hanh_Controller_Plugin_Acl
	 **/
	public function getAclPlugin() {
		if (null === $this->_aclPlugin) {
			$front = Zend_Controller_Front::getInstance ();
			if ($front->hasPlugin ( 'Hanh_Controller_Plugin_Acl' )) {
				$this->_aclPlugin = $front->getPlugin ( 'Hanh_Controller_Plugin_Acl' );
			} else {
				$front->registerPlugin ( new Hanh_Controller_Plugin_Acl ( ) );
				$this->_aclPlugin = $this->getAclPlugin ();
			}
		}
		
		return $this->_aclPlugin;
	}
	
	/**
	 * Call the denyAccess function of the Acl Plugin object
	 *
	 * @return void
	 **/
	public function denyAccess() {
		$this->_aclPlugin->denyAccess ();
	}
}